﻿// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// This file is part of CodingEditor.
// Note:	This project is derived from Peter Project
//			(hosted on sourceforge and codeplex)
//
// Copyright (c) 2008-2009, CE Team
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


namespace CE.Classes
{
    using log4net;
    using log4net.Config;

    /// <summary>
    /// A simple utility class to output log messages
    /// </summary>
    public static class Logger
    {
        public enum LogLevel 
        {
            Debug,
            Error,
            Fatal,
            Info,
            Warn
        }

        private static readonly ILog _logger;

        /// <summary>
        /// Initializes the <see cref="Logger"/> class.
        /// </summary>
        static Logger()
        {
            _logger = LogManager.GetLogger(typeof(Logger));
            XmlConfigurator.Configure(new System.IO.FileInfo(Constants.ConfigFile));
        }

        /// <summary>
        /// Writes the log.
        /// </summary>
        /// <param name="logLevel">The log level.</param>
        /// <param name="log">The log.</param>
        public static void WriteLog(LogLevel logLevel, string log)
        {
            switch (logLevel) {
                case LogLevel.Debug: _logger.Debug(log); break;
                case LogLevel.Error: _logger.Error(log); break;
                case LogLevel.Fatal: _logger.Fatal(log); break;
                case LogLevel.Info: _logger.Info(log); break;
                case LogLevel.Warn: _logger.Warn(log); break;
            }
        }
    }
}